package com.qf.main.content.controller;

import com.qf.common.base.result.ResponseResult;
import com.qf.main.content.common.qo.DiscoveryClassificationQo;
import com.qf.main.content.entity.DiscoveryClassification;
import com.qf.main.content.service.DiscoveryClassificationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import kotlin.annotation.Repeatable;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author chengqiang
 * @Create 2024-01-20-14:01
 * @Description:
 */
@RestController
@RequestMapping("/discovery/classification")
@Api(tags = "发现")
@CrossOrigin
public class DiscoveryClassificationController {

    @Resource
    private DiscoveryClassificationService discoveryClassificationService;

    @GetMapping("/list")
    @ResponseBody
    @ApiOperation("查询全部发现分类")
    public ResponseResult<List<DiscoveryClassification>> listDiscoveryClassification(){
        List<DiscoveryClassification> discoveryClassifications = discoveryClassificationService.queryDiscoveryClassification();
        return ResponseResult.success(discoveryClassifications);
    }

    @PostMapping("/add")
    @ResponseBody
    @ApiOperation("添加发现分类")
    public ResponseResult<Integer> addDiscoveryClassification(@RequestBody DiscoveryClassificationQo discoveryClassificationQo){
        return ResponseResult.success(discoveryClassificationService.saveDiscoveryClassification(discoveryClassificationQo));
    }

    @DeleteMapping("/erase")
    @ResponseBody
    @ApiOperation("删除发现分类")
    public ResponseResult<Integer> eraseDiscoveryClassification(@RequestParam("id") Integer id){
        return ResponseResult.success(discoveryClassificationService.removeDiscoveryClassification(id));
    }



}
